package com.hermes.util.message;

import java.util.Map;
import java.util.TimerTask;

import javax.servlet.http.HttpServletRequest;

import com.hermes.biz.common.model.message.PostMessageUnitDO;
import com.hermes.biz.service.message.MessageReceiverServiceImpl;
import com.hermes.biz.sessionCenter.Qsession;
import com.hermes.biz.sessionCenter.SsionManager;
import com.hermes.util.push.ChatManager;

public class MessageTask extends TimerTask {
    public static HttpServletRequest  request;
    public ChatManager                chatManager;
    public MessageReceiverServiceImpl messageReceiverService;
    SsionManager                      ssionManager;

    @SuppressWarnings("deprecation")
    @Override
    public void run() {
        //		System.out.println("run function ...");
        //		 ssionManager = new SsionManager();
        //		 Map<String,Qsession> sctSessionMap = ssionManager.getAllSession();
        //		 
        ////		 Collection<ScriptSession> sessions = new HashSet<ScriptSession>();  
        ////	        sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext())  
        ////	                .getScriptSessionsByPage("/index.htm"));
        //	        Map<Long,PostMessageUnitDO> infoMap = messageReceiverService.getPostMessageInfo();
        //	        push(sctSessionMap, infoMap);
    }

    @SuppressWarnings("deprecation")
    private void push(Map<String, Qsession> sessions, Map<Long, PostMessageUnitDO> infoMap) {
        //			if()
        //			
        //		for(ScriptSession ss : sessions.){
        //			Util util = new Util(ss); 			
        //			long userid = (Long) ss.getAttribute("userid");
        //			if(infoMap.containsKey(userid)){
        //				int fansCount = infoMap.get(userid).getFans();
        //				int commentCount = infoMap.get(userid).getComment();
        //				int replyCount = infoMap.get(userid).getReply();
        //				util.setValue("msg", commentCount); 
        //			}
        //		}
    }

    //geters and setters
    public ChatManager getChatManager() {
        return chatManager;
    }

    public void setChatManager(ChatManager chatManager) {
        this.chatManager = chatManager;
    }

    public MessageReceiverServiceImpl getMessageReceiverService() {
        return messageReceiverService;
    }

    public void setMessageReceiverService(MessageReceiverServiceImpl messageReceiverService) {
        this.messageReceiverService = messageReceiverService;
    }
}
